package com.lin.mock.pay.server.controller;

import com.alibaba.fastjson2.JSONObject;
import com.lin.mock.pay.server.model.Result;
import com.lin.mock.pay.server.model.vo.CloseOrderVO;
import com.lin.mock.pay.server.model.vo.PrepayOrderVO;
import com.lin.mock.pay.server.model.vo.QueryOrderVO;
import com.lin.mock.pay.server.model.vo.RefundsOrderVO;
import com.lin.mock.pay.server.service.MockPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: linjiang
 * @date: 2024/12/13
 */
@RestController
@RequestMapping("/mock/pay/server/wechat")
public class WxPayServerContoller {
    @Autowired
    private MockPayService mockPayService;

    @PostMapping("/prepay")
    public Result<JSONObject> prepay(@RequestBody PrepayOrderVO body) {
        return Result.buildSuccess(mockPayService.prepay(body));
    }

    @PostMapping("/close")
    public String close(@RequestBody CloseOrderVO body) {
        mockPayService.close(body);
        return "success";
    }

    @PostMapping("/query")
    public String query(@RequestBody QueryOrderVO body) {
        mockPayService.query(body);
        return "success";
    }

    @PostMapping("/refund")
    public String refund(@RequestBody RefundsOrderVO body) {
        mockPayService.refund(body);
        return "success";
    }

}
